﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<List<CRM.Database.Model.ProductSystems>>" %>
<%--<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<CRM.Models.ProductSystems>>" %>--%>
<%@ Import Namespace="CRM.Models" %>
<%@ Import Namespace="CRM.Resourses" %>

<% Html.DevExpress().GridView(settings =>
                                    {
                                        settings.Name = "gdProductSystems";
                                        settings.KeyFieldName = "IdProductSystem";
                                        settings.CallbackRouteValues =
                                            new { Controller = "Dictionaries", Action = "ProductSystemsPartial" };
                                        settings.SettingsPager.PageSize = 20;

                                        //settings.Columns.Add(column =>
                                        //{
                                        //    column.Caption = "Id";
                                        //    column.FieldName = "IdProductSystem";
                                        //});
                                        
                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.ProductSystemRu;
                                            column.FieldName = "ProductSystemRu";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.ProductSystemDe;
                                            column.FieldName = "ProductSystemDe";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.ProductSystemEn;
                                            column.FieldName = "ProductSystemEn";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.ProductSystemSAP;
                                            column.FieldName = "ProductSystemSAP";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.ProductMark;
                                            column.FieldName = "IdProductMark";
                                            column.ColumnType = MVCxGridViewColumnType.ComboBox;
                                            var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
                                            if (comboBoxProperties != null)
                                            {
                                                var col = new CRM.Database.Model.ProductMarksCollection();
                                                comboBoxProperties.DataSource = col.ProductMarksActiveList;
                                                //comboBoxProperties.DataSource = DB.ProductMarks;
                                                //collection.EquipmentTypes;
                                                comboBoxProperties.TextField = "ProductMark";
                                                comboBoxProperties.ValueField = "IdProductMark";
                                                comboBoxProperties.ValueType = typeof(int);
                                            }
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.IsActive;
                                            column.FieldName = "IsActive";
                                            column.ColumnType = MVCxGridViewColumnType.CheckBox;
                                        });

                                        //
                                        //Добавление редактирования
                                        //
                                        settings.CommandColumn.Visible = true;
                                        settings.CommandColumn.NewButton.Visible = true;
                                        settings.CommandColumn.DeleteButton.Visible = false;
                                        settings.CommandColumn.EditButton.Visible = true;
                                        settings.SettingsBehavior.ConfirmDelete = true;
                                        settings.Settings.ShowFilterRow = true;
                                        settings.SettingsEditing.UpdateRowRouteValues = new { Controller = "Dictionaries", Action = "ProductSystemsPartialUpdate" };
                                        settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "Dictionaries", Action = "ProductSystemsPartialAdd" };
                                        settings.SettingsEditing.DeleteRowRouteValues = new { Controller = "Dictionaries", Action = "ProductSystemsPartialDelete" };

                                        settings.SettingsEditing.Mode = GridViewEditingMode.EditFormAndDisplayRow;
                                        settings.Width = Unit.Percentage(100);
                                        
                                    })
       .Bind(Model).GetHtml();
%>